﻿/************************************************************************

   Extended Silverlight Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://extendedsilverlight.codeplex.com/license

   Please purchase a commercial version of this toolkit if you are using
   it in a commercial product. The commercial versions support the project,
   and also include more features for each control, priority support,
   source code, updates, removed watermark, and a proprietary license.

   Visit http://xceed.com and follow @datagrid on Twitter.

  **********************************************************************/


namespace Xceed.Silverlight.ListBox
{
  internal class LayoutChangeInfo
  {
    internal LayoutChangeInfo()
    {
      this.XChange = double.NaN;
      this.YChange = double.NaN;
      this.WidthChange = double.NaN;
      this.HeightChange = double.NaN;

      this.MaximumHeightChange = double.NaN;
      this.MaximumWidthChange = double.NaN;
      this.OpacityChange = double.NaN;
      this.AngleChange = double.NaN;
      this.ScaleChange = double.NaN;
    }

    internal ChangeType ChangeType
    {
      get;
      set;
    }

    internal double XChange
    {
      get;
      set;
    }

    internal double YChange
    {
      get;
      set;
    }

    internal double WidthChange
    {
      get;
      set;
    }

    internal double HeightChange
    {
      get;
      set;
    }

    internal double MaximumWidthChange
    {
      get;
      set;
    }

    internal double MaximumHeightChange
    {
      get;
      set;
    }

    internal double OpacityChange
    {
      get;
      set;
    }

    internal double AngleChange
    {
      get
      {
        return m_angleChange;
      }
      set
      {
        if( m_angleChange != value )
        {
          m_angleChange = value;

          // This is done to avoid full spin of containers
          if( m_angleChange > 180.0d )
          {
            m_angleChange = -( 360 - m_angleChange );
          }

          if( m_angleChange < -180.0d )
          {
            m_angleChange = 360.0 + m_angleChange;
          }
        }
      }
    }

    internal double ScaleChange
    {
      get;
      set;
    }

    internal bool IsEmpty
    {
      get
      {
        return double.IsNaN( this.XChange ) && double.IsNaN( this.YChange )
            && double.IsNaN( this.WidthChange ) && double.IsNaN( this.HeightChange )
            && double.IsNaN( this.MaximumWidthChange ) && double.IsNaN( this.MaximumHeightChange )
            && double.IsNaN( this.AngleChange ) && double.IsNaN( this.OpacityChange )
            && double.IsNaN( this.ScaleChange );
      }
    }

    internal static LayoutChangeInfo CreateDefaultLayoutChangeInfo()
    {
      return new LayoutChangeInfo( );
    }

    private double m_angleChange = 0.0d;
  }

  internal enum ChangeType
  {
    ElementAdded,
    ElementRemoved,
    ElementChanged,
  }

}
